<!--修改密码-->
<template>
    <div class="chajoasse">
        <el-form label-width="120px" :model="form" :rules="rules" ref="ruleForm" status-icon>
            <el-form-item label="旧密码" prop="oldPwd">
                <el-input type="password" placeholder="请输入旧密码" v-model="form.oldPwd" ></el-input>
            </el-form-item>
            <el-form-item label="新密码" prop="newPwd">
                <el-input type="password" placeholder="请输入新密码" v-model="form.newPwd"></el-input>
            </el-form-item>
            <el-form-item label="确认新密码" prop="qnewPwd">
                <el-input type="password" placeholder="请输入确认新密码" v-model="form.qnewPwd"></el-input>

            </el-form-item>
            <el-form-item>
                <div class="mt20 cen">
                    <el-button type="primary">保存</el-button>
                    <el-button class="sdrtrty">重置</el-button>
                </div>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
    export default {
        data() {
            var validatePass2 = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请再次输入密码'));
                } else if (value !== this.form.newPwd) {
                    callback(new Error('两次输入密码不一致!'));
                } else {
                    callback();
                }
            };
            return {
                form: {
                    oldPwd: '',
                    newPwd: '',
                    qnewPwd: ''
                },
                rules: {
                    oldPwd: [{
                            required: true,
                            message: '请输入旧密码',
                            trigger: 'blur'
                        },
                        {
                            min: 6,
                            message: '只能输入6-20个字母、数字、下划线',
                            trigger: 'blur'
                        }
                    ],
                    newPwd: [{
                            required: true,
                            message: '请输入新密码',
                            trigger: 'blur'
                        },
                        {
                            min: 6,
                            message: '只能输入6-20个字母、数字、下划线',
                            trigger: 'blur'
                        }
                    ],
                    qnewPwd: [{
                            required: true,
                            message: '请确认新密码',
                            trigger: 'blur'
                        },
                        {
                            validator: validatePass2,
                            trigger: 'blur'
                        },
                        {
                            min: 6,
                            message: '只能输入6-20个字母、数字、下划线',
                            trigger: 'blur'
                        }
                    ]
                }
            }
        },
        components: {},
        methods: {},
        mounted() {}
    }

</script>
<style scoped>
    .chajoasse {
        padding-top: 100px;
        width: 480px;
        margin: auto;
    }

    .sdrtrty {
        margin-left: 40px
    }

</style>
